/**
 * Created by wxb on 2016/10/21.
 */
'use strict';

angular.module('BlurAdmin')
  .factory('systemManageUrl', function (publicFunc) {
    var prefix = '/kt/';
    var url = {
      user_info: {
        url: 'admin/user/{userId}',
        method: 'GET'
      },
      get_users: {
        url: 'admin/user',
        method: 'GET'
      },
      add_user: {
        url: 'admin/user',
        method: 'POST'
      },
      update_user: {
        url: 'admin/user/{userId}',
        method: 'PUT'
      },
      get_roles: {
        url: 'admin/role',
        method: 'GET'
      },
      get_role: {
        url: 'admin/role/{roleId}',
        method: 'GET'
      },
      add_role: {
        url: 'admin/role',
        method: 'POST'
      },
      update_role: {
        url: 'admin/role/{roleId}',
        method: 'PUT'
      },
      delete_role: {
        url: 'admin/role/{roleId}',
        method: 'DELETE'
      },
      menu_tree: {
        url: 'admin/menu/tree',
        method: 'GET'
      },
      get_menus: {
        url: 'admin/menu',
        method: 'GET'
      },
      add_menu: {
        url: 'admin/menu',
        method: 'POST'
      },
      update_menu: {
        url: 'admin/menu/{menuId}',
        method: 'PUT'
      },
      get_menu: {
        url: 'admin/menu/{menuId}',
        method: 'GET'
      },
      delete_menu: {
        url: 'admin/menu/{menuId}',
        method: 'DELETE'
      },
      product_token: {
        url: 'admin/config/uploadToken',
        method: 'GET'
      },
      apk_token: {
        url: 'admin/config/uploadToken',
        method: 'GET'
      },
      user_area: {
        url: 'admin/area/district',
        method: 'GET'
      },


    };
    return publicFunc.urlAddPrefix(url, prefix);
  })
  .service('systemManageService', function (httpService, systemManageUrl) {
    this.userInfo = function (userId) {
      return httpService.http({}, systemManageUrl.user_info, {userId: userId})
    };
    this.getUsers = function (queryParams) {
      return httpService.http({}, systemManageUrl.get_users, queryParams)
    };
    this.addUser = function (postData) {
      return httpService.http(postData, systemManageUrl.add_user, {})
    };
    this.updateUser = function (postData, userId) {
      return httpService.http(postData, systemManageUrl.update_user, {userId: userId})
    };
    this.getRoles = function () {
      return httpService.http({}, systemManageUrl.get_roles, {})
    };
    this.getRole = function () {
      return httpService.http({}, systemManageUrl.get_role, {})
    };
    this.addRole = function (postData) {
      return httpService.http(postData, systemManageUrl.add_role, {})
    };
    this.updateRole = function (postData, roleId) {
      return httpService.http(postData, systemManageUrl.update_role, {roleId: roleId})
    };
    this.deleteRole = function (roleId) {
      return httpService.http({}, systemManageUrl.delete_role, {roleId: roleId})
    };
    this.menuTree = function () {
      return httpService.http({}, systemManageUrl.menu_tree, {})
    };
    this.getMenus = function (queryParams) {
      return httpService.http({}, systemManageUrl.get_menus, queryParams)
    };
    this.addMenu = function (postData) {
      return httpService.http(postData, systemManageUrl.add_menu, {})
    };
    this.updateMenu = function (postData, menuId) {
      return httpService.http(postData, systemManageUrl.update_menu, {menuId: menuId})
    };
    this.getMenu = function () {
      return httpService.http({}, systemManageUrl.get_menu, {})
    };
    this.deleteMenu = function (queryParams) {
      return httpService.http({}, systemManageUrl.delete_menu, queryParams)
    };
    this.productToken = function () {
      return httpService.http({}, systemManageUrl.product_token, {})
    };
    this.apkToken = function () {
      return httpService.http({}, systemManageUrl.apk_token, {})
    };
    this.userArea = function (parentId) {
      return httpService.http({}, systemManageUrl.user_area, {parentId: parentId})
    };




  });
